import { Sprite, DIRECTIONS } from './sprites.js';

// Base entity class
export class Entity {
    constructor(x, y, sprite) {
        this.x = x;
        this.y = y;
        this.sprite = sprite;
        this.direction = DIRECTIONS.DOWN;
        this.moving = false;
    }

    update(timestamp) {
        if (this.moving) {
            this.sprite.update(timestamp);
        }
    }

    draw(ctx) {
        this.sprite.draw(ctx, this.x, this.y, this.direction);
    }
}

// Monster types and their properties
export const MONSTER_TYPES = {
    SLIME: {
        name: '史莱姆',
        health: 50,
        damage: 5,
        exp: 20,
        speed: 1,
        dropRate: 0.3,
        sprite: 'slime'
    },
    SKELETON: {
        name: '骷髅战士',
        health: 80,
        damage: 8,
        exp: 35,
        speed: 1.2,
        dropRate: 0.4,
        sprite: 'skeleton'
    },
    ORC: {
        name: '兽人战士',
        health: 120,
        damage: 12,
        exp: 50,
        speed: 0.8,
        dropRate: 0.5,
        sprite: 'orc'
    },
    DRAGON: {
        name: '小型龙',
        health: 200,
        damage: 20,
        exp: 100,
        speed: 1.5,
        dropRate: 1,
        sprite: 'dragon'
    }
};

// Equipment types and their properties
export const EQUIPMENT_TYPES = {
    WEAPONS: {
        WOODEN_SWORD: {
            name: '木剑',
            damage: 5,
            type: 'weapon',
            rarity: 'common',
            sprite: { x: 0, y: 0 }
        },
        IRON_SWORD: {
            name: '铁剑',
            damage: 10,
            type: 'weapon',
            rarity: 'common',
            sprite: { x: 1, y: 0 }
        },
        STEEL_SWORD: {
            name: '精钢剑',
            damage: 15,
            type: 'weapon',
            rarity: 'uncommon',
            sprite: { x: 2, y: 0 }
        },
        MAGIC_SWORD: {
            name: '魔法剑',
            damage: 20,
            magicDamage: 5,
            type: 'weapon',
            rarity: 'rare',
            sprite: { x: 3, y: 0 }
        }
    },
    ARMOR: {
        LEATHER_ARMOR: {
            name: '皮甲',
            defense: 5,
            type: 'armor',
            rarity: 'common',
            sprite: { x: 0, y: 1 }
        },
        IRON_ARMOR: {
            name: '铁甲',
            defense: 10,
            type: 'armor',
            rarity: 'common',
            sprite: { x: 1, y: 1 }
        },
        STEEL_ARMOR: {
            name: '精钢甲',
            defense: 15,
            type: 'armor',
            rarity: 'uncommon',
            sprite: { x: 2, y: 1 }
        },
        MAGIC_ARMOR: {
            name: '魔法甲',
            defense: 20,
            magicResist: 5,
            type: 'armor',
            rarity: 'rare',
            sprite: { x: 3, y: 1 }
        }
    },
    ACCESSORIES: {
        RING_OF_HEALTH: {
            name: '生命戒指',
            health: 20,
            type: 'accessory',
            rarity: 'uncommon',
            sprite: { x: 0, y: 2 }
        },
        RING_OF_STRENGTH: {
            name: '力量戒指',
            damage: 5,
            type: 'accessory',
            rarity: 'uncommon',
            sprite: { x: 1, y: 2 }
        },
        AMULET_OF_PROTECTION: {
            name: '守护项链',
            defense: 5,
            magicResist: 5,
            type: 'accessory',
            rarity: 'rare',
            sprite: { x: 2, y: 2 }
        }
    }
};

// Consumable items
export const CONSUMABLE_TYPES = {
    HEALTH_POTION: {
        name: '生命药水',
        healing: 50,
        type: 'consumable',
        rarity: 'common',
        sprite: { x: 0, y: 3 }
    },
    GREATER_HEALTH_POTION: {
        name: '大生命药水',
        healing: 100,
        type: 'consumable',
        rarity: 'uncommon',
        sprite: { x: 1, y: 3 }
    },
    STRENGTH_POTION: {
        name: '力量药水',
        tempDamage: 10,
        duration: 30000, // 30 seconds
        type: 'consumable',
        rarity: 'uncommon',
        sprite: { x: 2, y: 3 }
    },
    DEFENSE_POTION: {
        name: '防御药水',
        tempDefense: 10,
        duration: 30000, // 30 seconds
        type: 'consumable',
        rarity: 'uncommon',
        sprite: { x: 3, y: 3 }
    }
};

